Creating a Frame

In HTML, a frame is used to display multiple Web pages in the same Web page, at the same time. In other words, frame facilitates you to create more than one HTML document in an Internet Explorer window, where each HTML document is represented as a frame. HTML provides the facility to divide the Internet Explorer window into many sections by creating frames using the <iframe> tag.

How to creating a Frame in HTML 5

Prior to HTML 5, frames are created by using the <frameset> tag. With the advent of HTML , the <frameset>, <frame>, and <noframes> tages have been removed and replaced with a new tag called the <iframe> tag.

The iframe element defines inline frame that helps in embedding another HTML document within the main HTML document. It is also known as a nested browsing context. In addition, you can create an inline frame by using or providing the path of another HTML document or a Web page in the src attribute of the <iframe> tag. To create an inline frame, you need to specify the source of another HTML document in the src attribute of the <iframe tag. Mostly, an inline frame is used for displaying an advertisement on a Web page.

Note: in HTML 5, the frameborder, marginwidth, marginheight, and scrolling attributes are deprecated.

Let’s to the following steps to create a frame.


<!DOCTYPE html>
<head>
    <title> Example of using Frames on a Web page</title>
</head>
<body>
<h3> Inline frames</h3>
<iframe src="https://fastread.in"></iframe>
<iframe src=”tutor.html”></iframe>
</body>
</html> 

Save the document with the name CreatingFrames.html. And open on browser.

And save other document tutor.html


<!DOCTYPE html>
<head>
    <title>Fastread Tutorial</title>
</head>
<body>
<h1 align=”center”> HTML 5 Tutorial</h1>
<h3 align=”center”> CSS 3 Tutorial</h3>
</body>
</html>

Save the document as tutor.html

In the above you will shown, two inline frames are created on a Web page, where one frame shows the content of Google website; whereas, another frame displays the content of another HTML document.